import { EntityModel } from '@midwayjs/orm';
import { Column, JoinColumn, ManyToOne, OneToOne } from 'typeorm';
import { BaseModel } from '../utils/base.model';
import { TbFlow } from './TbFlow';
import { TbFlowNode } from './TbFlowNode';

/**
 * 流程线表
 */
@EntityModel()
export class TbFlowLine extends BaseModel {
  @Column({
    comment: '流程ID',
  })
  flowId: number;

  @ManyToOne(() => TbFlow, flow => flow.lines)
  @JoinColumn()
  flow: TbFlow;

  @Column({
    comment: '上一个节点id',
  })
  prevNodeId: number;

  @Column({
    comment: '下一个节点id',
  })
  nextNodeId: number;

  @OneToOne(() => TbFlowNode)
  @JoinColumn()
  prevNode: TbFlowNode;

  @OneToOne(() => TbFlowNode)
  @JoinColumn()
  nextNode: TbFlowNode;

  @Column({
    nullable: true,
    comment: '备注',
  })
  remark: string;
}
